package com.homework.action;

import java.sql.SQLException;

import javax.servlet.http.HttpServletRequest;

import org.apache.struts2.ServletActionContext;

import com.homework.bean.CourseBean;
import com.homework.bean.PageInfoBean;
import com.homework.bean.UserQuestionListBean;
import com.homework.service.QuestionService;

public class QuestionShowAction {
	
	private QuestionService questionService;
	private int courseId;
	private int intPage;
	
	public QuestionShowAction() {
		// TODO Auto-generated constructor stub
		questionService = new QuestionService();
	}
	
	public int getCourseId() {
		return courseId;
	}

	public void setCourseId(int courseId) {
		this.courseId = courseId;
	}

	public int getIntPage() {
		return intPage;
	}

	public void setIntPage(int intPage) {
		this.intPage = intPage;
	}

	// 问题列表
	public String questionShow() throws SQLException{
		HttpServletRequest request = ServletActionContext.getRequest();
		
		// courseBean
		CourseBean courseBean = new CourseBean();
		courseBean.setCourseId(String.valueOf(this.getCourseId()));
		// pageInfoBean
		PageInfoBean pageInfoBean = new PageInfoBean();
		pageInfoBean.setIntPage(this.getIntPage());
		// courseId
		int courseIdTemp = this.getCourseId();

		// 处理和设置pageInfoBean,userQuestionListBean
		UserQuestionListBean userQuestionListBean = new UserQuestionListBean();
		userQuestionListBean = questionService.questionShow(courseBean, pageInfoBean);
		request.setAttribute("userQuestionListBean", userQuestionListBean);
		request.setAttribute("pageInfoBean", pageInfoBean);
		request.setAttribute("courseId", courseIdTemp);

		return "Success";
	}
}
